﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WSAP;

namespace WSlabPrjTest
{
    public partial class TestForm : Form
    {
        public TestForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 板宽
        /// </summary>
        public double width
        {
            get
            {
                return Convert.ToDouble(this.SlabWidthTextbox.Text);
            }
        }

        /// <summary>
        /// 板长
        /// </summary>
        public double length
        {
            get
            {
                return Convert.ToDouble(this.SlabLengthTextbox.Text);
            }
        }

        /// <summary>
        /// 板厚
        /// </summary>
        public double thickness
        {
            get
            {
                return Convert.ToDouble(this.SlabThickTextbox.Text);
            }
        }

        /// <summary>
        /// 剖分尺度
        /// </summary>
        public double mesh
        {
            get
            {
                return Convert.ToDouble(this.MeshTextbox.Text);
            }
        }

        /// <summary>
        /// 均布荷载
        /// </summary>
        public double distLoad
        {
            get
            {
                return Convert.ToDouble(this.LoadTextbox.Text);
            }
        }

        /// <summary>
        /// 线荷载
        /// </summary>
        public double lineX
        {
            get
            {
                return Convert.ToDouble(this.LineEndXTextbox.Text);
            }
        }

        /// <summary>
        /// 线荷载
        /// </summary>
        public double lineY
        {
            get
            {
                return Convert.ToDouble(this.LineEndYTextbox.Text);
            }
        }

        /// <summary>
        /// 线荷载
        /// </summary>
        public double lineLoad
        {
            get
            {
                return Convert.ToDouble(this.LineLoadTextbox.Text);
            }
        }

        /// <summary>
        /// 点荷载
        /// </summary>
        public double ptX
        {
            get
            {
                return Convert.ToDouble(this.ConXTextbox.Text);
            }
        }

        /// <summary>
        /// 点荷载
        /// </summary>
        public double ptY
        {
            get
            {
                return Convert.ToDouble(this.ConYTextbox.Text);
            }
        }

        /// <summary>
        /// 点荷载
        /// </summary>
        public double ptLoad
        {
            get
            {
                return Convert.ToDouble(this.ConValueTextbox.Text);
            }
        }

        /// <summary>
        /// 角度
        /// </summary>
        public int theta
        {
            get
            {
                return Convert.ToInt32(this.ThetaTextbox.Text); 
            }
        }

        /// <summary>
        /// 洞口大小
        /// </summary>
        public double hole
        {
            get
            {
                return Convert.ToDouble(this.HoleTextbox.Text);
            }
        }

        /// <summary>
        /// 绘图类型
        /// </summary>
        public SlabChartEnum chartEnum
        {
            get
            {
                if (this.DefelectionRaidoButton.Checked) return SlabChartEnum.Deflection;
                else if (this.M11RadioButton.Checked) return SlabChartEnum.M11;
                else if (this.M22RadioButton.Checked) return SlabChartEnum.M22;
                else if (this.MmaxRadioButton.Checked) return SlabChartEnum.Mmax;
                else if (this.MminRadioButton.Checked) return SlabChartEnum.Mmin;
                else return SlabChartEnum.Deflection;
            }
        }

        /// <summary>
        /// 楼板分析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnalyzeButton_Click(object sender, EventArgs e)
        {
            //创建模型
            //var model = WSlabTest.GetWModelNet(this.width, this.length,
            //    this.FixRadioButton.Checked ? WSlabBoundCDT.Fixed : WSlabBoundCDT.Pin, this.hole);
            var model = WSlabTest.GetWModelNetWithCantiConstraint(this.width, this.length);
            //var model = WSlabTest.GetComplexWModelNet();
            //增加荷载
            model.AddLoad(this.distLoad, this.lineX, this.lineY, this.lineLoad, this.ptX, this.ptY, this.ptLoad);
            //求解
            if (!model.Analyze(this.thickness, (int)this.mesh, 0)) return;
            //绘图
            model.ToGraphics(new SlabChartParam
            {
                ChartEnum = this.chartEnum,
                Theta = this.theta
            });
            //return true;
        }
    }
}
